|
1
|
|
|
import React from 'react'; |
|
2
|
|
|
import Container from './Application/Container'; |
|
3
|
|
|
import ApplicationView, {IAdapter} from './Application/View/Application'; |
|
4
|
|
|
import Model from './Application/View/Application/Model'; |
|
5
|
|
|
import {ILanguageSetup} from './Language/ChangeLanguageSetup'; |
|
6
|
|
|
|
|
7
|
|
|
interface IProperties { |
|
8
|
|
|
} |
|
9
|
|
|
|
|
10
|
|
|
interface IState { |
|
11
|
|
|
loadedLanguage: string, |
|
12
|
|
|
menuOpen: boolean, |
|
13
|
|
|
loadedPage: typeof React.Component | null |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
export default class Application extends React.Component<IProperties, IState> { |
|
17
|
|
|
adapter: IAdapter; |
|
18
|
|
|
|
|
19
|
|
|
constructor(props: IProperties) { |
|
20
|
4 |
|
super(props); |
|
21
|
|
|
|
|
22
|
4 |
|
this.state = { |
|
23
|
|
|
loadedLanguage: Container.language.setupObserver.value.languageCode, |
|
24
|
|
|
menuOpen: Container.menuOpenState.value, |
|
25
|
|
|
loadedPage: null |
|
26
|
|
|
}; |
|
27
|
|
|
|
|
28
|
4 |
|
Container.language.setupAdapter.addListener(this.onLanguageLoaded.bind(this)); |
|
29
|
4 |
|
Container.moduleStateAdapter.addListener(this.onModuleLoaded.bind(this)); |
|
30
|
4 |
|
Container.menuOpenStateAdapter.onChange = this.onMenuChange.bind(this); |
|
31
|
4 |
|
this.adapter = Container.applicationAction.adapter; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
componentDidMount(): void { |
|
35
|
4 |
|
Container.language.changeLanguageSetup.interact({languageCode: 'de-de'}, {}).then(); |
|
36
|
4 |
|
Container.moduleNameState.value = 'HelloWorld'; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
onLanguageLoaded(oldValue: ILanguageSetup, newValue: ILanguageSetup) { |
|
40
|
1 |
|
this.setState({loadedLanguage: newValue.languageCode}); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
onMenuChange(oldValue: boolean, newValue: boolean) { |
|
44
|
1 |
|
this.setState({menuOpen: newValue}); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
onModuleLoaded(oldValue: typeof React.Component | null, newValue: typeof React.Component | null) { |
|
48
|
1 |
|
this.setState({loadedPage: newValue}); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
render(): React.ReactNode { |
|
52
|
7 |
|
const model: Model = Container.applicationPresenter.present(); |
|
53
|
|
|
|
|
54
|
7 |
|
return <ApplicationView model={model} adapter={this.adapter} />; |
|
55
|
|
|
} |
|
56
|
|
|
} |